package com.jzhao.jpre.model;

import java.math.BigDecimal;
import java.util.List;

import com.jzhao.jpre.base.Assembler;
import com.jzhao.jpre.base.StringPublicDeal;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.dao.DataAccessException;
import com.jzhao.jpre.base.IDGenerator;

import com.jzhao.jpre.model.dao.BillInfDao;


public class TestBillInf {
	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext(
		"beans.xml");

		BillInfDao billInfDao = (BillInfDao) context.getBean("billInfDao");

		BillInf billInf = new BillInf();
		
		StringPublicDeal cc = (StringPublicDeal) Assembler.getInstance("chineseConversion");
	
	/*
		try {
			billInf.setBillNo("20040101");
			billInf.setMrchCode("00010002");
			billInf.setSubCode("001");
			
			billInf.setBillDate("20070101");
			billInf.setBillTime("010101");
			
			billInf.setUserCode("555");
			billInf.setBillState("1");
			billInf.setPrtFlag("0");
			
			
			
			billInf.setCurrAmt(new BigDecimal("0.01"));
		
			
			billInf.setTranDate("20070101");
			

			billInf.setJourNo("00000030");
			
			
			billInfDao.insert(billInf);
		} 
		catch (DataAccessException dae) {
			System.out.println("Insert Failed!");
			System.out.println(dae.getMessage());
		}
	
	
    
	
	
	  /*
		try {
			billInfDao.updateBillStatCancel("20070101","00000030");
		} catch (DataAccessException dae) {
			System.out.println("update Failed!");
		}
		
		/*
		try {
			billInfDao.updatePrtFlag("00000125","1");
		} catch (DataAccessException dae) {
			System.out.println("update Failed!");
		}
		
		
		/*
		try {
			billInfDao.deleteByUserCode("00010002","555");
		} catch (DataAccessException dae) {
			System.out.println("delete Failed!");
		}
		
	*/	
		
		try {
			billInf = billInfDao.selectByBillNo("10000125");
			System.out.println("setMrchCode = " + billInf.getMrchCode()+"end");
			System.out.println("BillInf = " + billInf.getBillInf()+"end");
			System.out.println("CurrAmt = " + billInf.getCurrAmt()+"end");
			System.out.println("BillState = " + billInf.getBillState()+"end");
						
		} catch (DataAccessException dae) {
			System.out.println("journal is not Exist!");
			System.out.println(dae.getMessage());
		}
		
		
	/*
		
		List billInfs = billInfDao.selectByJourNo("20070101","00000030");
		for (int i = 0; i < billInfs.size(); i++) {
			billInf = (BillInf) billInfs.get(i);
			if (billInf != null) {
				System.out.println("setMrchCode = " + billInf.getMrchCode()+"end");
				System.out.println("BillInf = " + billInf.getBillInf() +"end");
				System.out.println("CurrAmt = " + billInf.getCurrAmt()+"end");
				System.out.println("BillState = " + billInf.getBillState()+"end");
			}
		}
	*/
		
	
		
	}
}

	